#include "wxsgridsizer.h"

namespace {
  wxsRegisterItem<wxsGridSizer> Reg( _T( "GridSizer" ), _T( "GridSizer" ), wxsTSizer, _T( "布局" ), 60 );
}

wxsGridSizer::wxsGridSizer( wxsItemResData* Data ):
  wxsSizer( Data, &Reg.Info ), Cols( 3 ), Rows( 0 ) {
}

wxSizer* wxsGridSizer::OnBuildSizerPreview( wxWindow* Parent ) {
  return new wxGridSizer( Rows, Cols, VGap.GetPixels( Parent ), HGap.GetPixels( Parent ) );
}

void wxsGridSizer::OnBuildSizerCreatingCode() {
  switch( GetLanguage() ) {
    case wxsCPP: {
      AddHeader( _T( "<wx/sizer.h>" ), GetInfo().ClassName, hfInPCH );
      Codef( _T( "%C(%d, %d, %s, %s);\n" ), Rows, Cols,
             VGap.GetPixelsCode( GetCoderContext() ).wx_str(),
             HGap.GetPixelsCode( GetCoderContext() ).wx_str() );
      return;
    }
    case wxsUnknownLanguage:
    default: {
      wxsCodeMarks::Unknown( _T( "wxsGridSizer::OnBuildSizerCreatingCode" ), GetLanguage() );
    }
  }
}

void wxsGridSizer::OnEnumSizerProperties( M_Code_unused long Flags ) {
  WXS_LONG( wxsGridSizer, Cols, _T( "Cols" ), _T( "cols" ), 0 );
  WXS_LONG( wxsGridSizer, Rows, _T( "Rows" ), _T( "rows" ), 0 );
  WXS_DIMENSION( wxsGridSizer, VGap, _T( "V-Gap" ), _T( "V-Gap in dialog units" ), _T( "vgap" ), 0, false );
  WXS_DIMENSION( wxsGridSizer, HGap, _T( "H-Gap" ), _T( "H,y-Gap in dialog units" ), _T( "hgap" ), 0, false );
}
